import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

/**
 * @Projectname: java8
 * @Filename: StreamTest
 * @Author: WangYang
 * @Data:2025/3/24
 * @Description: TODO
 */
public class StreamTest {

    public static void main1(String[] args) {
        List<User> list = new ArrayList<>();
        list.add(new User("1","1",1));
        list.add(new User("2","2",2));
        list.add(new User("3","3",3));
        list.add(new User("4","4",4));
        list.add(new User("5","5",5));
        list.add(new User("6","6",6));
        list.add(new User("7","7",7));
        list.add(new User("7","7",7));

        Stream<User> stream = list.stream();
        stream.filter(e -> Integer.parseInt(e.getId())>2).forEach(System.out::println);
        System.out.println("======================================");
        System.out.println("======================================");
        list.stream().limit(3).forEach(System.out::println);
        System.out.println("======================================");
        list.stream().skip(3).forEach(System.out::println);
        System.out.println("======================================");
        System.out.println("======================================");
        list.stream().distinct().forEach(System.out::println);


        //Stream<User> parallelStream = list.parallelStream();

        //IntStream stream1 = Arrays.stream(new int[]{1, 2, 3, 4, 5, 6, 7});

        //Stream<Integer> integerStream = Stream.of(1, 2, 3, 4, 5, 6);

    }

    public static void main(String[] args) {
        List<User> list = new ArrayList<>();
        list.add(new User("1","1",1));
        list.add(new User("2","2",2));
        list.add(new User("3","3",3));
        list.add(new User("4","4",4));
        list.add(new User("5","5",5));
        list.add(new User("6","6",6));
        list.add(new User("7","7",7));
        list.add(new User("7","7",7));

        List<String> list1 = Arrays.asList("aa", "bb", "cc", "dd");
        list1.stream().map(str -> str.toUpperCase()).forEach(System.out::println);

        System.out.println("====================");
        list.stream().map(e -> e.getName()).filter(str -> str=="3").forEach(System.out::println);

        System.out.println("====================");

        List<Integer> list2 = Arrays.asList(1, 34, 3, 56, 35, 67);
        list2.stream().sorted().forEach(System.out::println);

        System.out.println("====================");
        System.out.println("====================");
        System.out.println("====================");
        System.out.println("====================");
        list.stream().sorted((o1, o2) -> Integer.compare(Integer.parseInt(o1.getId()),Integer.parseInt(o2.getId()))).forEach(System.out::println);
    }

}
